<?php
/**
 * Template Name:captcha_check
 */
/**

 * 接受用户登陆时提交的验证码

 */
define( 'WP_USE_THEMES', false );
require_once( $_SERVER[ 'DOCUMENT_ROOT' ] . '/wp-load.php' );
 session_start();

//1. 获取到用户提交的验证码

if(isset($_POST["captcha"])&&$_POST["captcha"]!="")
{
	$captcha = $_POST["captcha"];
}else{
	$captcha ='nocaptcha';
}
var_dump($_SESSION["captcha"]);
echo $captcha;

//2. 将session中的验证码和用户提交的验证码进行核对,当成功时提示验证码正确，并销毁之前的session值,不成功则重新提交

if(strtolower($_SESSION["captcha"]) == strtolower($captcha)){

    echo "right captcha";

    $_SESSION["captcha"] = "";

}else{

    echo "wrong captcha";

}
?>